package com.wish233.wiliwilivideo.controller;

import com.wish233.wiliwiliapi.domain.vo.VideoVO;
import com.wish233.wiliwilicommon.common.BaseResponse;
import com.wish233.wiliwilicommon.common.ErrorCode;
import com.wish233.wiliwilicommon.common.ResultUtils;
import com.wish233.wiliwilicommon.exception.BusinessException;
import com.wish233.wiliwilicommon.exception.ThrowUtils;
import com.wish233.wiliwilivideo.domain.dto.video.VideoStatusRequest;
import com.wish233.wiliwilivideo.service.AdminService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author WHH
 * 加入管理员审核视频逻辑
 */
@RestController
@RequestMapping("/admin")
public class AdminController {

    @Resource
    private AdminService adminService;

    @GetMapping("/listNotreViewed")
    public BaseResponse<List<VideoVO>> listNotreViewed(@RequestParam Integer current, @RequestParam Integer pageSize) {
        ThrowUtils.throwIfParamNull(current, pageSize);
        ThrowUtils.throwIf(current < 1 || pageSize > 10, new BusinessException(ErrorCode.PARAMS_ERROR));
        return ResultUtils.success(adminService.listNotReviewed(current, pageSize));
    }

    @PostMapping("/setStatus")
    public BaseResponse<Boolean> setStatus(@RequestBody VideoStatusRequest videoStatusRequest) {
        ThrowUtils.throwIfParamNull(videoStatusRequest, videoStatusRequest.getId(), videoStatusRequest.getStatus());
        return ResultUtils.success(adminService.setStatus(videoStatusRequest));
    }

}
